package org.usmile.algorithms.huawei.acm;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

// https://blog.csdn.net/qq_34465338/article/details/128611597
public class _统计匹配的二元组个数 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int M = sc.nextInt();
        sc.nextLine();
        int N = sc.nextInt();
        sc.nextLine();
        String[] aStr = sc.nextLine().split(" ");
        Map<Integer, Integer> aMap = new HashMap<>();
        for (int i = 0; i < M; i++) {
            int num = Integer.parseInt(aStr[i]);
            aMap.put(num, aMap.getOrDefault(num, 0) + 1);
        }
        int count = 0;
        String[] bStr = sc.nextLine().split(" ");
        for (int i = 0; i < N; i++) {
            int num = Integer.parseInt(bStr[i]);
            if (aMap.containsKey(num)) {
                count += aMap.get(num);
            }
        }

        System.out.println(count);
    }
}
